<template>
  <div align="center">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>登录</span>
      </div>
      <div class="text item">
        <el-form :inline="true" v-model="user" class="demo-form-inline">
          <el-form-item label="账号">
            <el-input v-model="user.username" placeholder="账号"></el-input>
          </el-form-item>
          <br />
          <el-form-item label="密码">
            <el-input v-model="user.password" type="password" placeholder="密码"></el-input>
          </el-form-item>
          <br />
          <el-form-item>
            <el-button type="primary" @click="onSubmit">登录</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      user: {}
    };
  },
  methods: {
    async onSubmit() {
      const _this = this;
      var qs = require("qs");
      // let {data} = await this.$http.post("/login", this.user);
      // //后台定义 返回数据 ok == 登录成功 no == 登录失败
      // if (data == "ok") {
      //     this.$message('恭喜你登录成功！');
      // } else {
      //     this.$message.error('登录失败！');
      // }
      axios({
        method: "post",
        url:'http://localhost:8088/tb-userinfo/web/dengLu',
       // url: "http://localhost:8088/users/web/login",
        data: qs.stringify(this.user),
        headers: {
          "content-type": "application/x-www-form-urlencoded"
        }
      }).then(function(resp) {
        console.log(resp);
        //sessionStorage.setItem("token", resp.data.data.token);
        //sessionStorage.setItem("userId", resp.data.data.userId);
        //window.sessionStorage.setItem('head_portrait',resp.data.data.head_portrait)
        //window.sessionStorage.setItem('authority',resp.data.data.authority)
        //window.sessionStorage.setItem('username',resp.data.data.username)
        //window.sessionStorage.setItem('identity_id',resp.data.data.identity_id)
       // window.sessionStorage.setItem('password',resp.data.data.password)
       // window.sessionStorage.setItem('phone',resp.data.data.phone)
       // window.sessionStorage.setItem('remark',resp.data.data.remark)
       // window.sessionStorage.setItem('address',resp.data.data.address)
        // this.$router.push('/Users');
        _this.$router.replace({ path: "/users" });
      });
    }
  }
};
</script>
